﻿using System;
using System.Linq;

namespace ALDIOrganizer
{    
    public partial class Sheet
    {        
        public Cell this[int col, int row]
        {
            get
            {
                return Cells[row][col];
            }
        }

        public Cell this[Weekday pDay, Int64 pEmpID]
        {
            get
            {
                var column = pDay.ToInt1();
                var row = this[pEmpID];
                return row[column];
            }
        }

        public Cell this[Weekday pDay, Guid pGuid]
        {
            get
            {
                var column = pDay.ToInt1();
                var row = this[pGuid];
                return row[column];
            }
        }

        public Cell[] this[RowTag pTag]
        {
            get
            {
                switch (pTag.MyType)
                {
                    case RowTagType.LongInt:
                        {
                            return this[pTag.Int64Value];
                        }
                    case RowTagType.GUID:
                        {
                            return this[pTag.GuidValue];
                        }
                    default:
                        {
                            return null;
                        }
                }
            }
        }


        public Cell[] this[Int64 empID]
        {
            get
            {
                return (from row in Cells
                        where row[0].EmployeeID == empID
                        select row).SingleOrDefault();
            }
        }

        public Cell[] this[Guid guid]
        {
            get
            {
                return (from row in Cells
                        where row[0].GetIdentifier == guid
                        select row).SingleOrDefault();
            }
        }        
    }
}
